<?php
	$crash = $crash?:array();
	if(!isset($crash['title'])) $crash['title']="Oops! Fatal error.";
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
	<title><?php echo $crash['title']; ?></title>
	<style type="text/css">
		html {
			background-color: #FFC080;
		}
		h2, h4, p {
			margin: 0.25em;
		}
		h2 {
			color: red;
		}
		div.error {
			display: block;
			border: 1px solid gray;
			margin-bottom: 6px;
		}
		div.output {
			padding: 12px;
			background-color: white;
		}
	</style>
</head>
<body>
<h1><?php echo $crash['title']; ?></h1>
<?php
// display errors if they have been recorded
if(isset($crash['errors'])) {
	echo "<h3>Internal error log:</h3>".PHP_EOL;
	foreach($crash['errors'] as &$err) {
		echo "<div class='error'>".PHP_EOL;
		echo "<h2>".nl2br($err['title'],true)."</h2>".PHP_EOL;
		if(isset($err['subtitle']))
			echo "<h4>{$err['subtitle']}</h4>".PHP_EOL;
		if(isset($err['body']))
			echo "<pre>{$err['body']}</pre>".PHP_EOL;
		echo "</div>".PHP_EOL;
	}
}
// display output until the moment of crash (if it exists)
if(isset($crash['output'])) {
	echo "<h3>Output until the moment of crash:</h3>".PHP_EOL;
	echo "<div class='output'>".$crash['output']."</div>".PHP_EOL;
} ?>
</body>
</html>